<template>
  <el-menu
      mode="horizontal"
      class="el-menu"
      @open="handleOpen"
      @close="handleClose"
      background-color="#fff"
      :active-text-color="theme"
      :router="true"
      :default-active="$route.path"
      :unique-opened="true"
      :collapse="isCollapse"
      :collapse-transition="true"
  >
    <m-menu-item
        :data="item"
        v-for="item in menu"
        :key="item.path"
    ></m-menu-item>
  </el-menu>
</template>

<script>
import MMenuItem from "./MMenuItem";
export default {
  name: "MMenuHorizontal",
  data() {
    return {};
  },
  components: {
    MMenuItem,
  },
  props: {
    logo: {
      type: [Object, String],
    },
    title: {
      type: String,
    },
    isCollapse: {
      type: Boolean,
      default: false,
    },
  },
  computed: {
    menu() {
      return this.$store.state.MUI.MMenu.data;
    },
    theme() {
      return this.$store.state.MUI.settings.theme;
    },
  },
  mounted() {},
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath);
    },
    handleClose(key, keyPath) {
      // console.log(key, keyPath);
    },
    toggleisCollapse() {
      this.$emit("update:isCollapse", !this.isCollapse);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "@/MUI/style/var.scss";

$menuBackgroundColor: #fff;
$menuBackgroundColorActive: mix($mainColor, #fff, 10%);
$menuColor: rgba(0, 0, 0, 0.8);
//rgb(48, 65, 86);
/*.MyMenu {
  //width: px2(200);
  height: 100%;
  background-color:  $menuBackgroundColor;
  color: $menuColor;
  padding-top: px2(84);
  padding-bottom: px2(50);
  box-sizing: border-box;
  border-right: px2(1) solid $borderColor;
  position: relative;
  transition: width 0.4s;
  .menuBox{
    height: 100%;
    width: 100%;
    overflow-x: hidden;
    padding-bottom: px2(40);

    .menu-icon{
      display: inline-block;
      margin-right: px2(4);
      width: px2(20);
    }
  }

  .logoBox {
    margin: 0 auto;
    text-align: center;
    padding:  px2(25) px2(0);
    height: px2(80);
    width: 100%;
    position: absolute;
    top: 0;
    left:0;
    text-align: center;
    white-space: nowrap;
    .logo {
      display: inline-block;
      margin: 0 auto;
      max-width: 80%;
      height: px2(30);
      margin-bottom: px2(10);
      //margin-right: px2(10);
      //margin-left: px2(10);
      padding: 0 px2(10);
    }
    .titleBox{
      vertical-align: top;
      max-width: px2(120);
      display: inline-block;
      color: $menuColor;
      margin: 0 auto;
      text-align: center;
      line-height: px2(30);
      font-size: px2(16);
      font-weight: bold;
    }
  }
  .toggleCollapse{
    position: absolute;
    bottom: px2(1);
    left:0;
    text-align: center;
    width: 100%;
    height: px2(48);
    line-height: px2(48);
    border-top: px2(1) solid $borderColor;
    background: #fff;
    &:hover{
      background: $menuBackgroundColorActive;
      color: $mainColor;
      cursor: pointer;
    }
    &.collapse{
      .icon{
        transform: rotateY(180deg);
      }

    }
  }
}


.el-submenu{
  &.is-active{
    .el-submenu__title{
      color:  $mainColor!important;
      .menu-icon{
        color:  $mainColor;
      }
    }
  }
}*/

/*.el-menu {
  height: 100%;
  width: 100%;
  border: 0!important;
  color: $menuColor;
  background-color: $menuBackgroundColor;
}*/

.el-submenu__title {
  color: $menuColor !important;
}
/*.el-menu-item{
  color: $menuColor;
}

.el-menu-item:hover,.el-submenu__title:hover{
  background-color:  $menuBackgroundColorActive!important;
}*/
.el-menu-item.is-active {
  // background-color:  $menuBackgroundColorActive!important;
  //color: $mainColor!important;
  border-bottom-color: transparent !important;
  position: relative;
  height: 100%;
  color: #1c6eff;
  font-size: px2(12);
  font-weight: bold;
  &:after {
    content: "";
    width: px2(24);
    height: px2(2);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: px2(46);
    background-color: $mainColor;
  }
  .menu-icon {
  }
}

.el-menu-item-group {
  background-color: $menuBackgroundColor !important;
  .el-menu-item-group__title {
    padding: 0;
  }
}
.el-menu--horizontal > .el-menu-item {
  height: 48px;
}
.el-menu--horizontal > .el-menu-item {
  font-size: px2(12);
  color: $fontColorW;
  height: 48px !important;
  line-height: 48px !important;
}
.el-menu--horizontal > .el-submenu .el-submenu__title {
  height: 48px !important;
  line-height: 48px !important;
}
</style>
